<template>
  <div id="app">
    <header class="mint-header" style="font-size: 18px;">
      <div class="mint-header-button is-left">
        <button class="mint-button mint-button--default mint-button--normal" style="font-size: 15px;" @click="option">
          <span class="mint-button-icon">
            <i class="mintui mintui-back" />
          </span>
          <label class="mint-button-text">返回</label>
        </button>
      </div>
      <h1 class="mint-header-title">公告中心</h1>
      <div class="mint-header-button is-right" />
    </header>
    <mt-navbar v-model="status" class="page_part">
      <mt-tab-item id="1">我发布的</mt-tab-item>
      <mt-tab-item id="2">通知我的</mt-tab-item>
    </mt-navbar>
    <mt-tab-container v-model="status">
      <mt-tab-container-item id="1">
        <div v-for="(item, index) in list" :key="index" class="bgc_white p_10 border_t width_90 margin_center" @click="goinfo (item)">
          <div class="he border_b1 pb_10">
            <div>{{ item.hash.username }}</div>
            <div>{{ item.hash.createtime }}</div>
          </div>
          <div>
            <div class="pt_10 fw">{{ item.hash.title }}</div>
            <div class="pt_10"> {{ item.hash.context }}</div>
          </div>
        </div>
      </mt-tab-container-item>
      <mt-tab-container-item id="2">
        <div v-for="(item, index) in list1" :key="index" class="bgc_white p_10 border_t width_90 margin_center" @click="goinfo (item)">
          <div class="he border_b1 pb_10">
            <div>{{ item.hash.username }}</div>
            <div>{{ item.hash.createtime }}</div>
          </div>
          <div>
            <div class="pt_10 fw">{{ item.hash.title }}</div>
            <div class="pt_10"> {{ item.hash.context }}</div>
          </div>
        </div>
      </mt-tab-container-item>
    </mt-tab-container>
    <!-- <div style="width:40px;height:40px;background-color:#26A2ff;border-radius:40px;color:white;text-align:center;display:flex;align-items:center;justify-content:center;">
      <div style="font-size:24px;line-height:20px;">+</div>
    </div> -->
    <div class="box weizhi" v-show="canfabu" @click="gonuxt('annouce','发布公告')">
      <img src="../static/fabu.png" alt class="img_tj">
    </div>

  </div>

</template>

<script>

import { Pagination } from 'vant'
export default {
  data () {
    return {
      status: '1',
      fabu: '',
      list: [],
      list1: [],
      canfabu: false,
      ts: this.newStore(),
    }
  },
  mounted () {
    this.getannouncementlist()
    this.getfabuqx()
  },
  methods: {

    goinfo (item) {
      this.$router.push({
        name: 'announcement_details',
        query: { msgid: item.hash.msgid }
      })
      console.log(item, 'item')
    },
    getfabuqx () {
      const req = {
        handle: '67A5B6FEF17D97DECF116BDF95B95C0B843B7A441565EC6C4A6860EBB8D9E769',
        'supid': '107',
        'pid': localStorage.getItem('pid')
      }
      this.spost(this.ts, '/mainservlet', req).then(ts => {
        if (ts.d.sflag == 'success') {
          console.log(ts.d.data.operation1, "ts.d");
          let fabu = ts.d.data.operation1[0].hash.privstr;
          console.log(fabu);
          console.log(fabu.indexOf('10702'));
          if (fabu.indexOf('10702') >= 0) {
            this.canfabu = true;
          }

        }
        console.log(this.list, '22222222')
      })
    },
    getannouncementlist () {
      const req = {
        handle: '0191283F93927EDB050783D3551EBA108C9CC6D91F18050F53A04F5FE3BD407E',
        msgtype: '',
        title: '',
        createtime_begin: '',
        createtime_end: '',
        start: '0',
        limit: "100000",
        status: '0'
      }
      this.spost(this.ts, '/mainservlet', req).then(ts => {
        if (ts.d.sflag == 'success') {
          this.list = ts.d.data.operation1
        }
        console.log(this.list, '22222222')
      })
      const req1 = {
        handle: '0191283F93927EDB050783D3551EBA10D378DC084872ED09F33AC00D936FAE5A',
        msgtype: '',
        title: '',
        createtime_begin: '',
        createtime_end: '',
        start: '0',
        limit: "100000",
        status: '1'
      }
      console.log(this.list, '11111111')
      this.spost(this.ts, '/mainservlet', req1).then(ts => {
        if (ts.d.sflag == 'success') {
          this.list1 = ts.d.data.operation1
        }
        console.log(this.list1, '22222222')
      })

    },
    option () {
      this.$router.push({
        name: 'jbrhome',
        query: {
          name: ''
        }
      })
    },
    gonuxt (val, name) {
      this.$router.push({ name: val, query: { name: name } })
    }
  }
}
</script>
<style>
html,
body,
#app {
  height: 100%;
  background-color: #f3f3f3;
}
.he {
  display: flex;
  justify-content: space-between;
}
.bgc_white {
  background-color: #fff;
}
.p_10 {
  padding: 10px;
}
.border_b1 {
  border-bottom: 1px solid #f3f3f3;
}
.pb_10 {
  padding-bottom: 10px;
}
.pt_10 {
  padding-top: 10px;
}
.border_t {
  border-top: 2px solid #26a2ff;
}
.width_90 {
  width: 94%;
}
.margin_center {
  margin: 20px auto 0 auto;
}
.fw {
  font-weight: bold;
}
.img_tj {
  width: 40px;
  height: 40px;
}
.weizhi {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 999;
}
</style>